//234 - 回文序列
class Solution {
    public boolean isPalindrome(ListNode head) {
        if(head == null){
            return true;
        }
        ListNode f = head;
        ListNode s = head;
        while(f != null && f.next != null){
            f = f.next.next;
            s = s.next;
        }
        ListNode prev = s;
        ListNode cur = s.next;
        while(cur != null){
            ListNode curN = cur.next;
            cur.next = prev;
            prev = cur;
            cur = curN;
        }
        while(head != prev){
            if(head.next == prev){
                if(head.val == prev.val){
                    return true;
                }
            }
            if(head.val != prev.val){
                return false;
            }
            head = head.next;
            prev = prev.next;
        }
        return true;
    }
}
public class Test {
}
